package com.bw.educate.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bw.educate.entity.EduCourseBase;
import com.bw.educate.entity.EduUserCourse;
import com.bw.educate.mapper.EduUserCourseMapper;
import com.bw.educate.service.IEduUserCourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Date;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 在线教育-五组
 * @since 2020-08-12
 */
@Service
public class EduUserCourseServiceImpl extends ServiceImpl<EduUserCourseMapper, EduUserCourse> implements IEduUserCourseService {

    @Autowired
    private EduUserCourseMapper userCourseMapper;

    @Override
    public List<EduCourseBase> getListById(Long id) {
        return userCourseMapper.getListById(id);
    }

    @Override
    public void addSave(Long courseId, Long uid) {
        EduUserCourse eduUserCourse = new EduUserCourse();
        eduUserCourse.setCourseId(courseId);
        eduUserCourse.setUserId(uid);
        eduUserCourse.setCreateTime(new Date());
        userCourseMapper.insert(eduUserCourse);
    }

    @Override
    public Integer getCourseById(Long id) {
        return userCourseMapper.getCourseById(id);
    }
}
